<div class="popup_body">
    <div class="ui_table">
        <form method="post">
            <input type="hidden" name="divideId" value="${divideId}">
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td width="80" align="right">换电次数：</td>
                    <td>
                        <input type="number" class="text easyui-validatebox" name="amount" required="required" min="0" id="amount_id"
                               maxlength="11"/>
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">机构类型：</td>
                    <td>
                        <input id="org_type" editable="false" style="width: 182px; height: 30px;"
                               class="easyui-combobox" name="orgType" required
                               data-options="
                                valueField: 'id',
                                textField: 'text',
                                url: '${contextPath}/security/hdw/exchange_amount_money_divide_detail/add_orgType.htm',
                                onSelect: function(rec){
                                var url = '${contextPath}/security/hdw/exchange_amount_money_divide_detail/add_orgId.htm?typeId='+rec.id;
                                $('#org_id').combobox('reload', url);
                                }">
                    </td>
                </tr>
                <tr>
                    <td width="80" align="right">机构：</td>
                    <td>
                        <input id="org_id" editable="false" style="width: 182px; height: 30px;" name="orgId"
                               class="easyui-combobox" required
                               data-options="valueField:'id',textField:'text'">
                    </td>
                </tr>
                <tr>
                    <td width="80" align="right">分配比例：</td>
                    <td>
                        <input type="number" class="text easyui-validatebox" name="percent" required="required" min="0"
                               validType="percentunique[$('#amount_id').val(),${divideId}]" maxlength="11"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_red ok">确定</button>
    <button class="btn btn_border close">关闭</button>
</div>
<script>
    $(function () {
        var pid = '${pid}',
                win = $('#' + pid),
                form = win.find('form');

        win.find('button.ok').click(function () {
            form.form('submit', {
                url: '${contextPath}/security/hdw/exchange_amount_money_divide_detail/create.htm',
                success: function (text) {
                    var json = $.evalJSON(text);
                <@app.json_jump/>
                    if (json.success) {
                        $.messager.alert('提示信息', '操作成功', 'info');
                        win.window('close');
                    } else {
                        $.messager.alert('提示信息', json.message, 'info');
                    }
                }
            });
        });
        win.find('button.close').click(function () {
            win.window('close');
        });
        $('#org_type').combobox({
            onLoadSuccess: function () {
                var id = $("input[name='orgType']").val();
                if (id != "") {
                    $('#org_id').combobox({
                        valueField: 'id',
                        textField: 'text',
                        url: '${contextPath}/security/hdw/exchange_amount_money_divide_detail/add_orgId.htm?typeId=' + id
                    });
                }
            }
        });
    })
</script>
